
****INDIVIDUAL FORECASTS
use "$jfqa_rep/21_DJIA_convexity_20.dta", clear

qui{
merge 1:m year month day using "$jfqa_rep/Shiller_Individual_Ests.dta"
keep if _merge==3
drop _merge

sort year month day
drop if abs(dow_1m)>=.5

gen monthyear=ym(year, month)

gen wret_1=(1+ret_5)*(1+ret_1)*(1+ret_2)*(1+ret_3)*(1+ret_4)-1
gen wret_2=(1+ret_10)*(1+ret_6)*(1+ret_7)*(1+ret_8)*(1+ret_9)-1
gen wret_3=(1+ret_15)*(1+ret_11)*(1+ret_12)*(1+ret_13)*(1+ret_14)-1
gen wret_4=(1+ret_20)*(1+ret_16)*(1+ret_17)*(1+ret_18)*(1+ret_19)-1
gen wret_5=(1+ret_25)*(1+ret_21)*(1+ret_22)*(1+ret_23)*(1+ret_24)-1
gen wret_6=(1+ret_30)*(1+ret_26)*(1+ret_27)*(1+ret_28)*(1+ret_29)-1
gen wret_7=(1+ret_35)*(1+ret_31)*(1+ret_32)*(1+ret_33)*(1+ret_34)-1
gen wret_8=(1+ret_40)*(1+ret_36)*(1+ret_37)*(1+ret_38)*(1+ret_39)-1
gen wret_9=(1+ret_45)*(1+ret_41)*(1+ret_42)*(1+ret_43)*(1+ret_44)-1
gen wret_10=(1+ret_50)*(1+ret_46)*(1+ret_47)*(1+ret_48)*(1+ret_49)-1
gen wret_11=(1+ret_55)*(1+ret_51)*(1+ret_52)*(1+ret_53)*(1+ret_54)-1
gen wret_12=(1+ret_60)*(1+ret_56)*(1+ret_57)*(1+ret_58)*(1+ret_59)-1
gen wret_13=(1+ret_65)*(1+ret_61)*(1+ret_62)*(1+ret_63)*(1+ret_64)-1
gen wret_14=(1+ret_70)*(1+ret_66)*(1+ret_67)*(1+ret_68)*(1+ret_69)-1
gen wret_15=(1+ret_75)*(1+ret_71)*(1+ret_72)*(1+ret_73)*(1+ret_74)-1
gen wret_16=(1+ret_80)*(1+ret_76)*(1+ret_77)*(1+ret_78)*(1+ret_79)-1

collapse dow* wret*, by( year month day monthyear)

gen obs=_n
tsset obs
}

*4 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	
*8 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	
*12 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^9*wret_9)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^10*wret_10)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^11*wret_11)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^12*wret_12)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))

*16 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^9*wret_9)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^10*wret_10)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^11*wret_11)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^12*wret_12)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^13*wret_13)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^14*wret_14)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^15*wret_15)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^16*wret_16)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	
****INSTITUTIONAL FORECASTS
use "$jfqa_rep/21_DJIA_convexity_20.dta", clear

qui{
merge 1:m year month day using "$jfqa_rep/Shiller_Inst_Ests.dta"
keep if _merge==3
drop _merge

sort year month day

drop if year<1993

gen monthyear=ym(year, month)

drop if abs(dow_1m)>=.5

gen wret_1=(1+ret_5)*(1+ret_1)*(1+ret_2)*(1+ret_3)*(1+ret_4)-1
gen wret_2=(1+ret_10)*(1+ret_6)*(1+ret_7)*(1+ret_8)*(1+ret_9)-1
gen wret_3=(1+ret_15)*(1+ret_11)*(1+ret_12)*(1+ret_13)*(1+ret_14)-1
gen wret_4=(1+ret_20)*(1+ret_16)*(1+ret_17)*(1+ret_18)*(1+ret_19)-1
gen wret_5=(1+ret_25)*(1+ret_21)*(1+ret_22)*(1+ret_23)*(1+ret_24)-1
gen wret_6=(1+ret_30)*(1+ret_26)*(1+ret_27)*(1+ret_28)*(1+ret_29)-1
gen wret_7=(1+ret_35)*(1+ret_31)*(1+ret_32)*(1+ret_33)*(1+ret_34)-1
gen wret_8=(1+ret_40)*(1+ret_36)*(1+ret_37)*(1+ret_38)*(1+ret_39)-1
gen wret_9=(1+ret_45)*(1+ret_41)*(1+ret_42)*(1+ret_43)*(1+ret_44)-1
gen wret_10=(1+ret_50)*(1+ret_46)*(1+ret_47)*(1+ret_48)*(1+ret_49)-1
gen wret_11=(1+ret_55)*(1+ret_51)*(1+ret_52)*(1+ret_53)*(1+ret_54)-1
gen wret_12=(1+ret_60)*(1+ret_56)*(1+ret_57)*(1+ret_58)*(1+ret_59)-1
gen wret_13=(1+ret_65)*(1+ret_61)*(1+ret_62)*(1+ret_63)*(1+ret_64)-1
gen wret_14=(1+ret_70)*(1+ret_66)*(1+ret_67)*(1+ret_68)*(1+ret_69)-1
gen wret_15=(1+ret_75)*(1+ret_71)*(1+ret_72)*(1+ret_73)*(1+ret_74)-1
gen wret_16=(1+ret_80)*(1+ret_76)*(1+ret_77)*(1+ret_78)*(1+ret_79)-1

collapse dow* wret*, by( year month day monthyear)

gen obs=_n
tsset obs
}
*4 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	
*8 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	

*12 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^9*wret_9)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^10*wret_10)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^11*wret_11)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^12*wret_12)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))

	
*16 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^9*wret_9)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^10*wret_10)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^11*wret_11)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^12*wret_12)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^13*wret_13)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^14*wret_14)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^15*wret_15)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^16*wret_16)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	


****ALL FORECASTS
use "$jfqa_rep/21_DJIA_convexity_20.dta", clear

qui{
merge 1:m year month day using "$jfqa_rep/Shiller_Inst_Ests.dta"
keep if _merge==3
drop _merge


preserve
tempfile copy

use "$jfqa_rep/21_DJIA_convexity_20.dta", clear

merge 1:m year month day using "$jfqa_rep/Shiller_Individual_Ests.dta"
keep if _merge==3
drop _merge

save `copy', replace

restore
append using `copy'

sort year month day

drop if year<1993

gen monthyear=ym(year, month)

drop if abs(dow_1m)>=.5

gen wret_1=(1+ret_5)*(1+ret_1)*(1+ret_2)*(1+ret_3)*(1+ret_4)-1
gen wret_2=(1+ret_10)*(1+ret_6)*(1+ret_7)*(1+ret_8)*(1+ret_9)-1
gen wret_3=(1+ret_15)*(1+ret_11)*(1+ret_12)*(1+ret_13)*(1+ret_14)-1
gen wret_4=(1+ret_20)*(1+ret_16)*(1+ret_17)*(1+ret_18)*(1+ret_19)-1
gen wret_5=(1+ret_25)*(1+ret_21)*(1+ret_22)*(1+ret_23)*(1+ret_24)-1
gen wret_6=(1+ret_30)*(1+ret_26)*(1+ret_27)*(1+ret_28)*(1+ret_29)-1
gen wret_7=(1+ret_35)*(1+ret_31)*(1+ret_32)*(1+ret_33)*(1+ret_34)-1
gen wret_8=(1+ret_40)*(1+ret_36)*(1+ret_37)*(1+ret_38)*(1+ret_39)-1
gen wret_9=(1+ret_45)*(1+ret_41)*(1+ret_42)*(1+ret_43)*(1+ret_44)-1
gen wret_10=(1+ret_50)*(1+ret_46)*(1+ret_47)*(1+ret_48)*(1+ret_49)-1
gen wret_11=(1+ret_55)*(1+ret_51)*(1+ret_52)*(1+ret_53)*(1+ret_54)-1
gen wret_12=(1+ret_60)*(1+ret_56)*(1+ret_57)*(1+ret_58)*(1+ret_59)-1
gen wret_13=(1+ret_65)*(1+ret_61)*(1+ret_62)*(1+ret_63)*(1+ret_64)-1
gen wret_14=(1+ret_70)*(1+ret_66)*(1+ret_67)*(1+ret_68)*(1+ret_69)-1
gen wret_15=(1+ret_75)*(1+ret_71)*(1+ret_72)*(1+ret_73)*(1+ret_74)-1
gen wret_16=(1+ret_80)*(1+ret_76)*(1+ret_77)*(1+ret_78)*(1+ret_79)-1

collapse dow* wret*, by( year month day monthyear)

gen obs=_n
tsset obs
}
*4 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	
*8 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	

*12 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^9*wret_9)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^10*wret_10)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^11*wret_11)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12) + ///
		({b2}^12*wret_12)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))

	

*16 lags
nl (dow_1m = {b0} + ///
	{b1}*(({b2}*wret_1)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^2*wret_2)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^3*wret_3)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^4*wret_4)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^5*wret_5)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^6*wret_6)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^7*wret_7)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^8*wret_8)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^9*wret_9)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^10*wret_10)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^11*wret_11)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^12*wret_12)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^13*wret_13)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^14*wret_14)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^15*wret_15)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16) + ///
		({b2}^16*wret_16)/({b2}+{b2}^2+{b2}^3+{b2}^4+{b2}^5+{b2}^6+{b2}^7+{b2}^8+{b2}^9+{b2}^10+{b2}^11+{b2}^12+{b2}^13+{b2}^14+{b2}^15+{b2}^16))), ///
		initial(b0 0 b1 1 b2 0.5) nolog vce(cluster monthyear)
test _b[/b2]=1
local b2 = sign(_b[/b2])
display "Ho: coef = 1, t-statistic = " , sqrt(r(F))
	

